next up previous contents index
Next: Types Up: Constants Previous: Ordinary constants

Typed constants

Typed constants serve to provide a program with initialized variables. Contrary to ordinary constants, they may be assigned to at run-time. The difference with normal variables is that their value is initialised when the program starts, whereas normal variables must be initialised explicitly.


Typed constant declaration

syntdiag898

syntdiag902

Given the declaration:
listing868
The following is a valid assignment:
listing870
Where Func is a function that returns a String.

Typed constants also allow you to initialize arrays and records. For arrays, the initial elements must be specified, surrounded by round brackets, and separated by commas. The number of elements must be exactly the same as number of elements in the declaration of the type.

As an example:
listing874

For constant records, you should specify each element of the record, in the form Field : Value, separated by commas, and surrounded by round brackets.

As an example:
listing877
The order of the fields in a constant record needs to be the same as in the type declaration, otherwise you'll get a compile-time error.


next up previous contents index
Next: Types Up: Constants Previous: Ordinary constants

Michael Van Canneyt
Fri Sep 25 09:15:40 MEST 1998